// uno.config.ts
import transformerDirectives from '@unocss/transformer-directives'
import transformerVariantGroup from '@unocss/transformer-variant-group'
import { defineConfig, presetUno } from 'unocss'

/** 变量 */
export const vars: Record<string, string> = {
  // 品牌色 / 常规
  'primary-6': '#1562FC',
  // 品牌色 / 悬浮
  'primary-5': '#3F84FD',
  // 品牌色 / 点击
  'primary-7': '#0D48D0',
  // 品牌色 / 特殊场景
  'primary-4': '#69A4FD',
  // 品牌色 / 一般禁用
  'primary-3': '#93C1FE',
  // 品牌色 / 文字禁用
  'primary-2': '#BDDCFE',
  // 品牌色 / 浅色/白底悬浮
  'primary-1': '#E8F4FF'
}
/** unocss theme 加入 bg-* text-* */
const unoColors: Record<string, string> = Object.keys(vars).reduce(
  (pre, curr) => {
    let key = curr
    if (curr.startsWith('color-border'))
      key = curr.replace('color-border', 'cb')
    if (curr.startsWith('color-text-')) {
      key = curr.replace('color-text', 'ct')
    } else if (curr.startsWith('color-fill-')) {
      key = curr.replace('color-fill', 'fill')
    }

    if (key.endsWith('-6')) key = key.replace('-6', '')
    return Object.assign(pre, { [key]: vars[curr] })
  },
  {}
)

export default defineConfig({
  shortcuts: {
    'fixed-container': 'w-1440px max-w-1440px mx-auto'
  },
  theme: {
    colors: unoColors
  },
  presets: [presetUno()],
  transformers: [transformerDirectives(), transformerVariantGroup()]
})
